package com.zdxf.util;

import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class UtilFun {
    public static String getPercent(int x, int y) {
        double d1 = x * 1.0;
        double d2 = y * 1.0;
        NumberFormat percentInstance = NumberFormat.getPercentInstance();
        // 设置保留几位小数，这里设置的是保留两位小数
        percentInstance.setMinimumFractionDigits(2);
        return percentInstance.format(d1 / d2);
    }

    public static SimpleDateFormat formatTime(String ftType) {
        SimpleDateFormat ft = new SimpleDateFormat(ftType);
        return ft;
    }

    public static int getQuarterOfYear() {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());
        return calendar.get(Calendar.MONTH) / 3 + 1;
    }

    /**
     * 判断字符串为空
     *
     * @param str
     * @return 返回格式：true-空，false-非空
     */
    public static final Boolean checkNull(String str) {
        Boolean ret = false;
        if (str == null || str.isEmpty() || str == "") {
            ret = true;
        }
        return ret;
    }
}


